package com.zyl.pts.service.serviceImpl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zyl.pts.domain.bean.Log;
import com.zyl.pts.mapper.LogMapper;
import com.zyl.pts.service.LogService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @version v1.0
 * @ProjectName: product_source
 * @Package: com.zyl.pts.service.serviceImpl
 * @ClassName: LogServiceImpl
 * @Description TODO()
 * @Author 翟玉龙
 * @Date 2024/11/19-13:51
 */
@Service
public class LogServiceImpl implements LogService {

    private final LogMapper logMapper;

    public LogServiceImpl(LogMapper logMapper) {
        this.logMapper = logMapper;
    }

    /**
     * 分页查询日志信息
     * @param pageNum 当前页码
     * @param pageSize 每页显示的记录数
     * @param originalIp 原始IP地址
     * @return {@link Page }<{@link Log }>
     */
    @Override
    public PageInfo<Log> queryLogPage(Integer pageNum, Integer pageSize, String originalIp) {
        Page<Log> page = PageHelper.startPage(pageNum, pageSize);
        List<Log> logs = logMapper.queryByConditional(originalIp);
        PageInfo<Log> pageInfo = new PageInfo<>(logs);
        page.close();
        return pageInfo;
    }
}
